/*
 * This class tests the IClassSlot class
 * by creating an instance with random values
 * and comparing its fields with the expected
 * values.
 */
package data;
import static org.junit.Assert.assertEquals;

import java.sql.Time;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;

import org.junit.Before;
import org.junit.Test;

/**
 * @author Harmandeep Singh
 * @version 1.0
 * @date May 14, 2011
 * Started test
 * @version 1.1
 * @date May 17,2011
 * Fixed days to work with enums
 * @version 1.2
 * @date May 18, 2011
 * Added testing of credits field
 */
public class ClassSlotTest {
	
	private ClassSlot classSlot;
	
	private TimeSlot timeSlot;

	private Time beg;

	private Time end;
	
	private String num;

	private String name;
	
	private String teach;
	
	private String[] num_array = {"TCSS 321", "TINST 207", "TCSS 142", "TINFO 300", 
			"TCES 310", "TCSS 390B", "TCSS 142", "TCSS 435", "TCES 390C"};
	
	private String[] name_array = {"Discrete Structures 1", "Working in a Virtual World", 
			"Intro to Object Oriented Programming", "Programming II for Info Professionals", 
			"Systems & Transforms", "Undergraduate Seminar in CSS", "TCSS 142 Lab (Wednesday ONLY)", 
			"Artificial Intelligence", "Undergraduate Seminar in CES"};
	
	private String[] teach_array = {"Tenenberg", "Fry", "Mayer", "Chung", "Sheng", "Zimmerman", 
			"Mayer", "Bichindartz", "Baiocchi"};
	
	private Set<ClassDays> days;
	
	private int r;
	
	private int c;
	

	/**
	 * Creates a new IClassSlot with random values
	 * @throws Exception
	 */
	@Before
	public void setUp() throws Exception {
		Random rand = new Random();
		days = new HashSet<ClassDays>();
		days.add(ClassDays.MONDAY);
		days.add(ClassDays.WEDNESDAY);
		r = rand.nextInt(8);
		num = num_array[r];
		name = name_array[r];
		teach = teach_array[r];
		timeSlot = new TimeSlot(days,rand.nextInt(),rand.nextInt());
		classSlot = new ClassSlot(timeSlot, num, name,'c', teach, c=rand.nextInt(9));
	  }
	
	/**
	 * A test to see if getDays() returns
	 * the expected days.
	 */
	@Test
	public void testGetDays() {
		assertEquals(classSlot.getTimeSlot().getDays(),days);
	}

	/**
	 * A test to see if getBeginTime() returns
	 * the expected begin time of this class.
	 */
	@Test
	public void testGetBeginTime() {
		assertEquals(classSlot.getTimeSlot().getStartTime(), beg);
	}

	/**
	 * A test to see if getEndTime() returns 
	 * the expected end time of this class.
	 */
	@Test
	public void testGetEndTime() {
		assertEquals(classSlot.getTimeSlot().getEndTime(), end);
	}

	/**
	 * A test to see if getClassNum() returns 
	 * the expected number of this class.
	 */
	@Test
	public void testGetClassNum() {
		assertEquals(classSlot.getClassNum(), num_array[r]);
	}

	/**
	 * A test to see if getClassTitle() returns 
	 * the expected title of this class.
	 */
	@Test
	public void testGetClassTitle() {
		assertEquals(classSlot.getClassTitle(), name_array[r]);
	}

	/**
	 * A test to see if getClassTeacher() returns 
	 * the expected teacher of this class.
	 */
	@Test
	public void testGetClassTeacher() {
		assertEquals(classSlot.getClassTeacher(), teach_array[r]);
	}
	
	public void testGetClassCredits() {
		assertEquals(classSlot.getClassCredits(), c);
	}

}
